# -*- coding:utf-8 -*-
# __author__ : "张百科"
# Date: 2021/1/26 15:34
# File: constructionlogs.py
# IDE: PyCharm

from rest_framework import serializers
from models.constructionlogs import ConstructionLogs

class ConstructionLogsSerializer(serializers.ModelSerializer):
    construction_id=serializers.IntegerField(label='施工项目ID',help_text='施工项目ID',required=True)
    process = serializers.IntegerField(label='当前进度', help_text='当前进度', read_only=True)
    process_display = serializers.SerializerMethodField(read_only=True)
    images = serializers.CharField(label='图片合集', help_text='图片合集', required=False)
    remark = serializers.CharField(label='备注', help_text='备注', required=False)
    create_time=serializers.DateTimeField(read_only=True)
    record_user=serializers.CharField(label='负责人', help_text='负责人', required=False)

    def get_process_display(self, obj):
        return obj.get_process_display()

    class Meta:
        model = ConstructionLogs
        exclude = ('is_delete',)